package com.gxa.meiye.admin.platform.controller;

import com.gxa.meiye.admin.platform.pojo.vo.AppListVo;
import com.gxa.meiye.admin.platform.pojo.vo.AppraiseVo;
import com.gxa.meiye.admin.platform.service.AppraiseService;
import com.gxa.meiye.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/appraise")
public class AppraiseController {

    @Autowired
    private AppraiseService appraiseService;

    @ApiOperation("评价列表")
    @GetMapping("/list")
    public Map userList(){
        List<AppListVo> appraiseVos = appraiseService.selectAppraList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(appraiseVos);
        return jsonResult.getMap();
    }

    @ApiOperation("查询评价")
    @PostMapping("/selectAppraises")
    public Map selectUsers(String select){
        List<AppListVo> appListVos = appraiseService.selectAppraises("%"+select+"%");
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(appListVos);
        return jsonResult.getMap();
    }

    @ApiOperation("删除评价")
    @PostMapping("/delAppraise")
    public Map delUsers(Integer id){
        appraiseService.delAppraise(id);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        return jsonResult.getMap();
    }
}
